package com.example.demo.publish;

import com.example.demo.config.AmqpConfig;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class FanoutPublish {

    @Autowired
    RabbitTemplate rabbitTemplate;

    /**
     * 发布广播消息.
     *
     * @param message .
     */
    public void fanoutPublish(String message) {
        try {
            rabbitTemplate.convertAndSend(AmqpConfig.FANOUT_EXCHANGE, null, message);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
